package com.e3.basdoc.currency.client;

import java.util.List;

import com.e3.basdoc.currency.model.CurrencyModel;
import com.e3.template.tgf.MyGFUI;
import com.e3.template.tgf.TGFEditorDialog;
import com.e3.template.tgf.TGFGridPanel;
import com.e3.template.tgf.TGFQueryDialog;
import com.e3.template.tgf.TGFSimpleFormPanel;
import com.e3.template.tgf.TGFStateMachine;
import com.e3.web.core.client.GXTHelper;
import com.e3.web.widget.client.BaseAction;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class CurrencyUI extends MyGFUI<CurrencyModel> {
	
	private CurrencyRPCServiceAsync service = CurrencyRPCService.Util.getInstance();

	@Override
	protected TGFSimpleFormPanel<CurrencyModel> createFormPanel() {
		return new CurrencyFormPanel();
	}

	@Override
	protected TGFGridPanel<CurrencyModel> createGridPanel() {
		return new CurrencyGridPanel();
	}

	@Override
	protected TGFQueryDialog<CurrencyModel> createQueryDialog() {
		return new CurrencyQueryDialog();
	}

	@Override
	protected TGFEditorDialog<CurrencyModel> createEditorDialog() {
		return new CurrencyEditorDialog();
	}

	@Override
	protected void executeDeleteService(final List<CurrencyModel> models,AsyncCallback<Void> callback) {
		service.deleteCurrencys(models,callback);
	}

	@Override
	protected String getCurrentLocalName() {
		return CurrencyMessages.INSTANCE.local_name();
	}

	@Override
	protected CurrencyModel createModelInstance() {
		return new CurrencyModel();
	}

	@Override
	protected BaseAction[] getToolButtonActions() {
		if(GXTHelper.isSuperAdmin()){
			return super.getToolButtonActions();
		}
		return new BaseAction[]{TGFStateMachine.QUERY_ACTION,TGFStateMachine.NEW_ACTION,TGFStateMachine.MODIFY_ACTION};
	}

}
